Skip to content

fix(eap): convert deprecated aggregation nested in aggregation-filter formulas#8093

Merged
MeredithAnya merged 1 commit into
masterfrom
meredith/6-22-26-filter
Jun 23, 2026
Merged

fix(eap): convert deprecated aggregation nested in aggregation-filter formulas#8093
MeredithAnya merged 1 commit into
masterfrom
meredith/6-22-26-filter

Conversation

@MeredithAnya

@MeredithAnya MeredithAnya commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

failure_rate()-style HAVING clauses sent to EndpointTraceItemTable fail with:

Column is not one of: aggregate, attribute key, formula, or conditional_formula

This happens for any request whose aggregation_filter.comparison_filter.formula contains a column using the deprecated aggregation field (rather than conditional_aggregation with no filter - see sentry-protos comment)

Root cause

The request pipeline runs AggregationToConditionalAggregationVisitor to upgrade every deprecated aggregation into the newer conditional_aggregation before the query is built, so the rest of the pipeline only deals with one kind.

AggregationComparisonFilterWrapper.accept only visited the filter's own top-level aggregation field — it never traversed into the columns of comparison_filter.formula. So a deprecated aggregation nested inside the filter's formula was never converted, and _column_to_expression rejected it.

The same formula in the SELECT columns works, because ColumnWrapper.accept already recurses into formula.left/formula.right. Only the aggregation-filter copy broke.

Fix

Recurse into the comparison filter's formula columns, matching ColumnWrapper's behavior.

Test

Added test_convert_aggregation_to_conditional_aggregation_in_comparison_filter_formula, which mirrors the failing query (a comparison filter comparing a formula with a nested deprecated aggregation). It fails without the fix and passes with it.

🤖 Generated with Claude Code

@MeredithAnya MeredithAnya requested review from a team as code owners June 23, 2026 17:36
… formulas

AggregationComparisonFilterWrapper.accept only visited the filter's own
top-level `aggregation` field — it never traversed into the columns of a
`comparison_filter.formula`. As a result, a deprecated `aggregation` nested
inside an aggregation-filter formula was never upgraded to
`conditional_aggregation`, and `_column_to_expression` later rejected it with
"Column is not one of: aggregate, attribute key, formula, or conditional_formula".

This broke failure_rate()-style HAVING clauses (count(...) / count(...) > x)
sent to EndpointTraceItemTable, e.g. api.organization-events and
api.dashboards.tablewidget. The same formula in the SELECT columns worked,
because ColumnWrapper already recurses into formula.left/right.

Recurse into the comparison filter's formula columns so the conversion applies
there too, matching ColumnWrapper's behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MeredithAnya MeredithAnya force-pushed the meredith/6-22-26-filter branch from 25d7209 to f16b6b0 Compare June 23, 2026 18:08
@MeredithAnya MeredithAnya merged commit 170f856 into master Jun 23, 2026
68 checks passed
@MeredithAnya MeredithAnya deleted the meredith/6-22-26-filter branch June 23, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants